﻿<catel:UserControl x:Class="Catel.Articles._03___MVVM.Examples.NestedUserControls.Room"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:NestedUserControls="clr-namespace:Catel.Articles._03___MVVM.Examples.NestedUserControls"
                   xmlns:catel="http://catel.codeplex.com"
                   x:TypeArguments="NestedUserControls:RoomViewModel">
    
    <!-- Content -->
    <Grid>
        <!-- Row definitions -->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Column definitions -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Name -->
        <TextBox Grid.Row="0" Text="{Binding Name}" />

        <!-- Creation date -->
        <Label Grid.Row="1" ContentStringFormat="Constructed at {0:HH:mm:ss.fff}" Content="{Binding ViewModelConstructionTime}" />

        <!-- Child objects (tables) -->
        <Button Grid.Row="2" Command="{Binding AddTable}" Content="Add table" />
        <Expander Grid.Row="3" Header="Tables" IsExpanded="False">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <ItemsControl Grid.Column="1" ItemsSource="{Binding Tables}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <NestedUserControls:Table DataContext="{Binding}" />
                                <Separator />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Expander>

        <!-- Child objects (beds) -->
        <Button Grid.Row="4" Command="{Binding AddBed}" Content="Add bed" />
        <Expander Grid.Row="5" Header="Beds" IsExpanded="False">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <ItemsControl Grid.Column="1" ItemsSource="{Binding Beds}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <NestedUserControls:Bed DataContext="{Binding}" />
                                <Separator />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </Expander>
    </Grid>
</catel:UserControl>
